package com.runen.infinitemovement.tool;

/**
 * Author: SXF
 * E-mail: xue.com.fei@outlook.com
 * CreatedTime: 2017/11/16 19:47
 * <p>
 * NoDoubleClickUtils
 */

public class NoDoubleClickUtils {

    private final static int SPACE_TIME = 500;
    private static long lastClickTime;

    public static void initLastClickTime() {
        lastClickTime = 0;
    }

    public synchronized static boolean isDoubleClick() {
        long currentTime = System.currentTimeMillis();
        boolean isClick2;
        if (currentTime - lastClickTime > SPACE_TIME) {
            isClick2 = false;
        } else {
            isClick2 = true;
        }
        lastClickTime = currentTime;
        return isClick2;
    }

}
